//
//  MovieViewController.m
//  分享_MPMoviePlayerController
//
//  Created by lanou on 15/9/5.
//  Copyright (c) 2015年 陈文杰. All rights reserved.
//

#import "MovieViewController.h"

@interface MovieViewController ()
@property(nonatomic, strong)MPMoviePlayerController *MP;
@end

@implementation MovieViewController
- (void)dealloc
{
    [_MP release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIButton *button = [UIButton buttonWithType:(UIButtonTypeSystem)];
    button.frame = CGRectMake(80, 300, 200, 40);
    [button setTitle:@"播放视频" forState:(UIControlStateNormal)];
    button.layer.borderWidth = 1.0;
    button.layer.cornerRadius = 10.0;
    [button addTarget:self action:@selector(didClickPlayButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:button];
}

- (void)didClickPlayButtonAction:(UIButton *)button
{
    NSURL *path = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"popeye" ofType:@"mp4"]];
    NSLog(@"%@",path);
    self.MP = [[MPMoviePlayerController alloc] initWithContentURL:path];
    self.MP.controlStyle = MPMovieControlStyleDefault;
    self.MP.shouldAutoplay = NO;
    
    [self.view addSubview:self.MP.view];
    [self.MP setFullscreen:YES animated:YES];
    [self.MP play];
}

- (void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker
{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
